package com.ywjt.pinkelephant.my.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.ywjt.pinkelephant.R;
import com.ywjt.pinkelephant.base.BaseActivity;
import com.ywjt.pinkelephant.my.adapter.ExtendIncomeAdapter;
import com.ywjt.pinkelephant.my.adapter.ExtendTeamAdapter;
import com.ywjt.pinkelephant.my.model.ExtendIncome;

import java.util.ArrayList;
import java.util.List;

public class ActivityExtendCenter extends BaseActivity implements View.OnClickListener {
private RecyclerView rcIncom,rcTeam,rcCommon;
private List<ExtendIncome> data;
private List<ExtendIncome> data1;
private ExtendIncomeAdapter incomeAdapter;
private ExtendTeamAdapter teamAdapter;
private LinearLayout llCanWithdraw;

    public static void actionStart(Context context ) {
        Intent intent = new Intent(context, ActivityExtendCenter.class);
        context.startActivity(intent);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.llCanWithdraw:
                ActivityWithDraw.actionStart(ActivityExtendCenter.this);
                break;
        }
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(true);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.activity_extend_center;
    }

    @Override
    protected void initView() {
        setTitleText("推广中心");
        rcIncom=findViewById(R.id.rcIncom);
        rcTeam=findViewById(R.id.rcTeam);
        rcCommon=findViewById(R.id.rcCommon);
        llCanWithdraw=findViewById(R.id.llCanWithdraw);
        llCanWithdraw.setOnClickListener(this::onClick);

        data=new ArrayList<>();
        ExtendIncome in1=new ExtendIncome();
        in1.setTitle("全部");
        in1.setMoney("¥0.00");
        data.add(in1);

        ExtendIncome in2=new ExtendIncome();
        in2.setTitle("今日");
        in2.setMoney("¥0.00");
        data.add(in2);

        ExtendIncome in3=new ExtendIncome();
        in3.setTitle("昨日");
        in3.setMoney("¥0.00");
        data.add(in3);

        ExtendIncome in4=new ExtendIncome();
        in4.setTitle("近30日");
        in4.setMoney("¥0.00");
        data.add(in4);
        incomeAdapter=new ExtendIncomeAdapter(data);
        rcIncom.setAdapter(incomeAdapter);
        rcIncom.setLayoutManager(new GridLayoutManager(ActivityExtendCenter.this,4,RecyclerView.VERTICAL,false));

        data1=new ArrayList<>();
        ExtendIncome t1=new ExtendIncome();
        t1.setTitle("全部达人");
        t1.setMoney("0");
        data1.add(t1);

        ExtendIncome t2=new ExtendIncome();
        t2.setTitle("新增直接达人");
        t2.setMoney("0");
        data1.add(t2);

        ExtendIncome t3=new ExtendIncome();
        t3.setTitle("新增间接达人");
        t3.setMoney("0");
        data1.add(t3);

        incomeAdapter=new ExtendIncomeAdapter(data1);
        rcTeam.setLayoutManager(new GridLayoutManager(ActivityExtendCenter.this,3,RecyclerView.VERTICAL,false));
        rcTeam.setAdapter(incomeAdapter);


        teamAdapter=new ExtendTeamAdapter(data1);
        rcCommon.setAdapter(teamAdapter);
        LinearLayoutManager layoutManager = new LinearLayoutManager(ActivityExtendCenter.this) {
            @Override
            public boolean canScrollVertically() {
                // 直接禁止垂直滑动
                return false;
            }
        };
        rcCommon.setLayoutManager(layoutManager);
    }

    @Override
    protected void initData() { }

    /**
     * 获取要使用的标题栏样式(此函数由子类重写)
     * @return
     */
    @Override
    protected int getTitleBarType() {
        return 0;
    }

}
